package Code.Objects.Characters.Player.Weapons;

import org.jrabbit.base.input.MouseHandler;
import org.jrabbit.base.managers.window.WindowManager;
import org.jrabbit.standard.game.graphics.skins.animation.AnimatedSkin;
import org.jrabbit.standard.game.graphics.skins.image.ImageSkin;
import org.jrabbit.standard.game.objects.Sprite;
import org.jrabbit.standard.game.objects.specialized.AnimatedSprite;

import Code.Objects.Characters.Player.Player;

public class PlayerWeapon extends AnimatedSprite
{
	protected Sprite weaponInfoBase;
	protected int cameraModePreference;
	
	protected ImageSkin icon;
	
	protected String name;
	protected String type;
	protected String description;
	
	protected float offset;
	
	protected Player owner;
	
	public PlayerWeapon(AnimatedSkin skin, Player p)
	{
		super(skin);
		owner = p;
		weaponInfoBase = new Sprite("Resources/Images/GUI/Game/Weapon Details/Weapon Info.png");
		weaponInfoBase.useScreenCoords(true);
		weaponInfoBase.location().set(WindowManager.getDisplayWidth() - weaponInfoBase.getScaledWidth() / 2,
					weaponInfoBase.getScaledHeight() / 2);
	}
	
	public void setOwner(Player p)
	{
		owner = p;
	}
	
	public Player getOwner()
	{
		return owner;
	}
	
	public int getCameraMode()
	{
		return cameraModePreference;
	}
	
	public void update(int delta)
	{
		super.update(delta);
		adjust();
		updateWeapon(delta);
	}
	
	protected double getTargetAngle()
	{
		return location.angleTowards(MouseHandler.location(false));
	}
	
	public void adjust()
	{
		rotation.set(getTargetAngle());
		location.set(owner.location());
		location.addPolar(offset, rotation.theta());
	}
	
	protected void updateWeapon(int delta)
	{
		
	}
	
	public void fire()
	{
		
	}
	
	public void renderGUI()
	{
		weaponInfoBase.render();
	}
	
	public void renderIcon()
	{
		icon.render();
	}
}